package com.hhss.qishi.utils;

import java.util.UUID;

/**
 * UUID工具类
 * 
 * @author Administrator
 *
 */
public class UUIDUtil {

	public static String getUUID() {
		UUID uuid = UUID.randomUUID();
		String str = uuid.toString();
		StringBuffer sb = new StringBuffer(str);
		StringBuffer temp = new StringBuffer();
		// 去掉"-"符号
		temp = temp.append(sb.substring(0, 8))
				.append(sb.substring(9, 13))
				.append(sb.substring(14, 18))
				.append(sb.substring(19, 23))
				.append(sb.substring(24));
		return temp.toString();
	}

	/**
	 * 获得5位的短uuid，一般作为md5加密的盐值用
	 * @return
	 */
	public static String getUUIDShort()	{
		UUID uuid = UUID.randomUUID();
		String str = uuid.toString();
		StringBuffer sb = new StringBuffer(str);
		StringBuffer temp = new StringBuffer();
		temp = temp.append(sb.substring(0, 5));
		return temp.toString();
	}
}
